package com.java.dormitorymanager.mvc.view;

import com.java.dormitorymanager.pojo.Manager;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @program: DormitoryManager
 * @description: 宿管修改自己信息
 * @author: ShuangChenYue
 * @create: 2021-05-19 10:15
 **/
@WebServlet(value = "/ViewUpdateDMDetail")
public class ViewUpdateDMDetailServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        System.out.println("您已进入宿管修改自己信息界面");

        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html");
        PrintWriter out = resp.getWriter();

        out.println("<!DOCTYPE html>");
        out.println("<html lang=\"en\">");
        out.println("<head>");
        out.println("<meta charset=\"UTF-8\">");
        out.println("<title>超管修改宿管信息</title>");
        out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost:8080/DormitoryManager/css/css-manager/updateCMDetail.css\">");
        out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost:8080/DormitoryManager/css/css-other/upIcon.css\">");
        out.println("</head>");
        out.println("<body>");
        out.println("<div id=\"divTitle\">");
        out.println("<h1 id=\"h01\">Super Manager</h1>");
        out.println("</div>");
        out.println("<div id=\"div01\">");
        out.println("<h1>Update CM Info</h1>");
        Manager manager = (Manager) req.getAttribute("managerForUpdate");
        out.println("<form id=\"updateCMForm\" action=\"/DormitoryManager/mvc/updateDMDetail.do?id="+manager.getId()+"\" method=\"post\">");

        out.println("<table>");
        out.println("<tr id=\"trId\">");
        out.println("<td id=\"tdID\"><i class=\"iconfontAD\">&#xe64d;</i><input id=\"inputId\" type=\"text\" name=\"id\" placeholder=\"id\" readonly=\"readonly\" value="+manager.getId()+"></td>");
        out.println("</tr>");
        out.println("<tr id=\"tr01\">");
        out.println("<td id=\"tdName\"><i class=\"iconfontAD\">&#xe669;</i><input id=\"inputName\" type=\"text\" name=\"name\" placeholder=\"name\" value="+manager.getName()+"></td>");
        out.println("</tr>");
        out.println("<tr id=\"tr02\">");
        out.println("<td id=\"tdPassword\"><i class=\"iconfontAD\">&#xe668;</i><input id=\"inputPassword\" type=\"text\" name=\"password\" placeholder=\"password\" value="+manager.getPassword()+"></td>");
        out.println("</tr>");
        out.println("<tr id=\"tr02\">");
        out.println("<td id=\"tdPassword\"><i class=\"iconfontAD\">&#xe635;</i><input id=\"inputPassword\" type=\"text\" name=\"status\" placeholder=\"status\" value="+manager.getStatus()+" readonly=\"readonly\" style=\"color:gray\"></td>");
        out.println("</tr>");

        out.println("<tr>");
        out.println("<td id=\"tdSubmit\" colspan=\"2\"><input id=\"inputSubmit\" type=\"submit\" value=\"Update\" title=\"点击更新\"></td>");
        out.println("</tr>");
        out.println("</table>");
        out.println("</form>");
        out.println("</div>");
        out.println("</body>");
        out.println("</html>");
        out.flush();
        out.close();
    }
}
